﻿namespace KseCms.Application
{
    [Authorize]
    public class ProductAppService : IDynamicApiController
    {
        private readonly IProductService _productService;
        public ProductAppService(IProductService productService)
        {
            _productService = productService;
        }

        public async Task<PagedList<ProductDto>> GetPageList([FromQuery]PageDto page)
        {
            return await _productService.GetList(page);
        }

        public async Task<ProductDto> Get(string id)
        {
            return await _productService.GetById(id);
        }

        public async Task<object> Create(ProductDto product)
        {
            await _productService.Create(product);

            return Results.Ok();
        }

        public async Task<object> Delete(string id)
        {
            await _productService.Delete(id);

            return Results.Ok();
        }

        public async Task<object> Update(ProductDto product)
        {
            await _productService.Update(product);

            return Results.Ok();
        }
    }
}